const mysql = require('../db/mysql57');

const createDao = {
    // 创建副卡密
    createSubCard(uid, name, card, endAt) {
        let sql = `insert into User (parentId, card, name, userTypeId, url, maxCount, endAt) values (?, ?, ?, (
                select id from UserType where name = ?
            ), ?, ?, ?)`;
        let data = [ uid, card, name, '副卡密用户', '/', -1, endAt ];
        return mysql.sqlExec(sql, data);
    },
    // 创建用户卡密
    createUserCard(uid, name, card, endAt) {
        let sql = `insert into User (parentId, card, name, userTypeId, url, maxCount, isEnable, endAt) values (?, ?, ?, (
                select id from UserType where name = ?
            ), ?, ?, ?, ?)`;
        let data = [ uid, card, name, '用户卡密用户', null, -1, 'false', endAt ];
        return mysql.sqlExec(sql, data);
    }
};

module.exports = createDao;
